//
//  MicroHeader.h
//  MateAdv
//
//  Created by 茶 on 2023/9/8.
//

#ifndef MicroHeader_h
#define MicroHeader_h

#define YYModelSynthCoderAndHash \
- (void)encodeWithCoder:(NSCoder *)aCoder { [self yy_modelEncodeWithCoder:aCoder]; } \
- (id)initWithCoder:(NSCoder *)aDecoder { return [self yy_modelInitWithCoder:aDecoder]; } \
- (id)copyWithZone:(NSZone *)zone { return [self yy_modelCopy]; } \
- (NSUInteger)hash { return [self yy_modelHash]; } \
- (BOOL)isEqual:(id)object { return [self yy_modelIsEqual:object]; } \
- (NSString *)description { return [self yy_modelDescription]; }

/**** UI尺寸 ****/
//获取屏幕宽度与高度
//#define SCREEN_WIDTH   [UIScreen mainScreen].bounds.size.width
//#define SCREEN_HEIGHT  [UIScreen mainScreen].bounds.size.height


/**
 *  自定义颜色宏
 */
#ifndef MAColor
#define MAColor(str) [UIColor colorWithHexString:str]
#endif

//获取本地对象（系统）
#define MAUserObj(key) [[NSUserDefaults standardUserDefaults] objectForKey:key]
#define MAUserBool(key) [[NSUserDefaults standardUserDefaults] boolForKey:key]
#define MAUserInteger(key) [[NSUserDefaults standardUserDefaults] integerForKey:key]

//字符串是否为空
#define MAStringIsEmpty(str) ([str isKindOfClass:[NSNull class]] || str == nil || [str length] < 1 ? YES : NO )
//数组是否为空
#define MAArrayIsEmpty(array) (array == nil || [array isKindOfClass:[NSNull class]] || array.count == 0)
//字典是否为空
#define MADictIsEmpty(dic) (dic == nil || [dic isKindOfClass:[NSNull class]] || dic.allKeys.count == 0)

/**
 *  判断block存在后执行
 */
#ifndef MABlock
#define MABlock(_b_, ...) if(_b_){_b_(__VA_ARGS__);}
#endif

/**** 数据判空 ****/
//字符串是否为空
#define kStringIsEmpty(str) ([str isKindOfClass:[NSNull class]] || str == nil || [str length] < 1 ? YES : NO )
//数组是否为空
#define kArrayIsEmpty(array) (array == nil || [array isKindOfClass:[NSNull class]] || array.count == 0)
//字典是否为空
#define kDictIsEmpty(dic) (dic == nil || [dic isKindOfClass:[NSNull class]] || dic.allKeys == 0)
//是否是空对象
#define kObjectIsEmpty(_object) (_object == nil \
|| [_object isKindOfClass:[NSNull class]] \
|| ([_object respondsToSelector:@selector(length)] && [(NSData *)_object length] == 0) \
|| ([_object respondsToSelector:@selector(count)] && [(NSArray *)_object count] == 0))

/**** 常用缩写 ****/
#define kApplication            [UIApplication sharedApplication]
#define kKeyWindow              [UIApplication sharedApplication].keyWindow
#define kAppDelegate            [UIApplication sharedApplication].delegate
#define kUserDefaults           [NSUserDefaults standardUserDefaults]
#define kNotifCenter            [NSNotificationCenter defaultCenter]
#define kUserModel              [MAUserManager sharedInstance]

/**
 MAStrongify
 MAStrongify用来解除循环引用
 */
#ifndef MAWeakify
#if DEBUG
#if __has_feature(objc_arc)
#define MAWeakify(object) __weak __typeof__(object) weak##_##object = object
#else
#define MAWeakify(object) __block __typeof__(object) block##_##object = object
#endif
#else
#if __has_feature(objc_arc)
#define MAWeakify(object) __weak __typeof__(object) weak##_##object = object
#else
#define MAWeakify(object) __block __typeof__(object) block##_##object = object
#endif
#endif
#endif

#ifndef MAStrongify
#if DEBUG
#if __has_feature(objc_arc)
#define MAStrongify(object) __typeof__(object) object = weak##_##object
#else
#define MAStrongify(object) __typeof__(object) object = block##_##object
#endif
#else
#if __has_feature(objc_arc)
#define MAStrongify(object) __typeof__(object) object = weak##_##object
#else
#define MAStrongify(object) __typeof__(object) object = block##_##object
#endif
#endif
#endif

#endif /* MicroHeader_h */
